var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (i, n) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, i) {
              t.__proto__ = i;
            }) ||
          function (t, i) {
            for (var n in i)
              Object.prototype.hasOwnProperty.call(i, n) && (t[n] = i[n]);
          })(i, n);
      };
      return function (i, n) {
        function e() {
          this.constructor = i;
        }
        if ("function" != typeof n && null !== n)
          throw new TypeError(
            "Class extends value " + String(n) + " is not a constructor or null"
          );
        t(i, n),
          (i.prototype =
            null === n
              ? Object.create(n)
              : ((e.prototype = n.prototype), new e()));
      };
    })(),
  NpcTaskListView = (function (t) {
    function i() {
      var i = t.call(this) || this;
      return (
        (i.diaListArr = []),
        WebSocketService.addListener({
          caller: i,
          code: 200,
          method: i.onLoadNpcListData,
        }),
        i.btn_npc_close.on(Laya.Event.CLICK, i, i.onClickNpcListData),
        (i.list_npc_task.selectEnable = !0),
        (i.list_npc_task.vScrollBarSkin = ""),
        i.list_npc_task.on(Laya.Event.CLICK, i, i.onDidClickNpcTaskAction),
        i
      );
    }
    return (
      __extends(i, t),
      (i.showNpcTaskListView = function () {
        return (
          null == this.npcTaskList && (this.npcTaskList = new i()),
          WebSocketService.send({ c: 200 }),
          this.npcTaskList
        );
      }),
      (i.prototype.onLoadNpcListData = function (t) {
        var i = [],
          n = t.npclist;
        n.length > 0 && (this.list_npc_task.visible = !0),
          (this.diaListArr = t.npclist);
        for (var e, s = "", o = 0; o < n.length; o++)
          (e = {
            itemName: n[o].name,
            id: n[o].id,
            name: n[o].name,
            typeId: n[o].typeId,
          }),
            i.push(e),
            "副本使者" == n[o].name &&
              ((Global.isFuBen = !0), (s = "副本使者"));
        (this.list_npc_task.visible = "副本使者" != s),
          (this.list_npc_task.array = i);
      }),
      (i.prototype.onClickNpcListData = function () {
        this.removeSelf();
      }),
      (i.prototype.onDidClickNpcTaskAction = function (t) {
        if ("" != t.target.name) {
          if (
            ((this.npcObj = this.list_npc_task.selectedItem),
            "btn_dialogue" == t.target.name)
          )
            if (1 == this.npcObj.typeId)
              Laya.stage.event("GameMainView", {
                code: "startRequestFight",
                data: this.npcObj,
              });
            else {
              if (2 == this.npcObj.typeId) {
                if (7e3 == this.npcObj.id) {
                  var i = NPCFuBenView.showFuBenNPCView();
                  return i.pos(0, 0), void Laya.stage.addChild(i);
                }
                return void (CommonActivityView.isThisNpc(this.npcObj.id)
                  ? CommonActivityView.open(this.npcObj.id)
                  : AddSkillCountView.isThisNpc(this.npcObj.id)
                  ? AddSkillCountView.open()
                  : CommunicateDialog.showCommunicationDialog(this.npcObj));
              }
              if (3 == this.npcObj.typeId)
                return void CommunicateDialog.showCommunicationDialog(
                  this.npcObj
                );
            }
          else NPCDetailDialog.showNPCDialog(this.npcObj);
          Laya.timer.once(2e3, this.list_npc_task, function () {
            this.selectedIndex > -1 && (this.selectedIndex = -1);
          });
        }
      }),
      (i.prototype.updateBaseNavHandlerFn = function (t, i) {
        if (!(i > this.list_npc_task.length)) {
          var n = t.getChildByName("btn_dialogue");
          1 == this.diaListArr[i].ap
            ? (n.skin = "comp/Home/btn_home_diago.png")
            : (n.skin = "comp/Home/btn_home_diago1.png");
        }
      }),
      i
    );
  })(ui.common.NpcTaskListViewUI);
